package day18.zhiyou100;

public class Demo05 {
    public static void main(String[] args) {
        // 构建三个子线程
        MyThread04 t01 = new MyThread04("t01");
        MyThread04 t02 = new MyThread04("t02");
        MyThread04 t03 = new MyThread04("t03");

        // 设置优先级  数字越大级别越高，级别越高线程执行优先级就越高
        t01.setPriority(Thread.MIN_PRIORITY);
        t02.setPriority(Thread.NORM_PRIORITY);
        t03.setPriority(Thread.MAX_PRIORITY);

        t01.start();
        t02.start();
        t03.start();

        // main线程打印
        System.out.println(t01.getName() +"优先级为：----->"+ t01.getPriority());
        System.out.println(t02.getName() +"优先级为：----->"+ t02.getPriority());
        System.out.println(t03.getName() +"优先级为：----->"+ t03.getPriority());
    }
}

// 自定义一个class
class MyThread04 extends Thread {

    public MyThread04(String name) {
        super(name);
    }

    @Override
    public void run() {
        for (int i = 0; i < 50; i++) {
            // getName() 线程名称
            System.out.println(this.getName()+"---->" + i);
        }
    }
}